import { request } from './request.js'
request.defaultData.baseUrl = 'http://cyjs.pzhkj.cn/'

export function getAnyList({
  page,
  caipiao_id,
  qihao,
  maQuantity,
  maChu,
  searchKey,
  orderField,
}) {
  return new Promise((resolve, reject) => {
    request
      .ajax({
        path: 'api/optional/getData',
        method: 'POST',
        data: {
          page,
          caipiao_id,
          qihao,
          maQuantity,
          maChu,
          orderField,
          searchKey,
        },
        afterAjax: res => {
          resolve(res)
        },
      })
      .catch(err => {
        reject(err)
      })
  })
}

export function getBraveList({
  page,
  caipiao_id,
  qihao,
  dan,
  tuo,
  chu,
  searchKey,
  orderField,
}) {
  return new Promise((resolve, reject) => {
    request
      .ajax({
        path: 'api/dantuo/stat',
        method: 'POST',
        data: {
          page,
          caipiao_id,
          qihao,
          dan,
          tuo,
          chu,
          orderField,
          searchKey,
        },
        afterAjax: res => {
          resolve(res)
        },
      })
      .catch(err => {
        reject(err)
      })
  })
}

export function getPlanSchemeList({ status = 1, page = 1 } = {}) {
  return new Promise((resolve, reject) => {
    request
      .ajax({
        path: 'api/optional/planScheme',
        method: 'POST',
        data: {
          status,
          page,
        },
        afterAjax: res => {
          resolve(res)
        },
      })
      .catch(err => {
        reject(err)
      })
  })
}
